from django.db import models

# Create your models here.


class UserInfoModel(models.Model):

    userid = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户唯一ID')
    name = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户名')
    sys_level = models.IntegerField(default=0, verbose_name='钉钉级别(角色)')

    def __str__(self):
        return self.userid

    class Meta:
        verbose_name = '钉钉用户信息'
        verbose_name_plural = verbose_name


class DdingDineModel(models.Model):
    dine_type = models.CharField(max_length=20, default='午餐', verbose_name='用餐类型')
    amount = models.CharField(max_length=20, null=True, blank=True, verbose_name='餐费金额')
    cut_ddine_time = models.CharField(max_length=20, default='18:00', verbose_name='截至订餐时间')
    ddine_end_time = models.CharField(max_length=20, default='13:30', verbose_name='结束取餐时间')
    stop = models.BooleanField(default=False, verbose_name='是否休假')
    stop_start_time = models.DateField(auto_now_add=False, verbose_name='饭堂休假开始时间')
    stop_end_time = models.DateField(auto_now_add=False, verbose_name='饭堂休假结束时间')

    def __str__(self):
        return self.amount

    class Meta:
        verbose_name = '全局设置'
        verbose_name_plural = verbose_name


class UserDdingDineModel(models.Model):
    userid = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户唯一ID')
    mobile = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户手机号')
    name = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户名')
    num = models.IntegerField(default=1, verbose_name='订餐数量')
    is_check = models.BooleanField(default=False, verbose_name='是否核验')
    code_time = models.DateTimeField(default=None, null=True, blank=True, verbose_name='初次扫码时间')
    amount = models.CharField(max_length=20, null=True, blank=True, verbose_name='餐费金额')
    ddine_time = models.DateField(auto_now_add=False, verbose_name='订单用餐日期')
    time = models.DateTimeField(auto_now_add=True, verbose_name='订单创建时间')
 
    def __str__(self):
        return self.userid

    class Meta:
        verbose_name = '用户订餐信息'
        verbose_name_plural = verbose_name


class ScanningCodes(models.Model):
    userid = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户唯一ID')
    mobile = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户手机号')
    name = models.CharField(max_length=20, null=True, blank=True, verbose_name='钉钉用户名')
    time = models.DateTimeField(auto_now_add=True, verbose_name='扫码时间')
 
    def __str__(self):
        return self.userid

    class Meta:
        verbose_name = '违规扫码'
        verbose_name_plural = verbose_name
